package com.ali.protobuf.single;

import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundHandlerAdapter;

/**
 * 自定义客户端处理器
 */
public class MyProtoBufSingleClientHandler extends ChannelInboundHandlerAdapter {
    /**
     * 通道激活
     */
    @Override
    public void channelActive(ChannelHandlerContext ctx) {
        UserPOJO.User.Builder builder = UserPOJO.User.newBuilder();
        builder.setId(1);
        builder.setCode("zs");
        builder.setName("张三");
        UserPOJO.User user = builder.build();
        //写入返回内容
        ctx.write(user);
        //刷新
        ctx.flush();
    }
}
